<template>
	<view class="enterprise">	
		<u-navbar
			title="企业名片"
			:border-bottom="false"  
	></u-navbar>
	
	<view v-if="this.loadding==true">
		<u-loading  mode="circle" ></u-loading>
	</view>
	<view v-if="enterprise==null" lass="enterprise__noresult">
		<u-empty text="暂无企业数据" mode="data"></u-empty>
		<view class="enterprise__noresult__add">
			<!-- <u-icon name="arrow-down-fill" size="1" color="#1b1b1b"></u-icon> -->
			<view @click="addEnterprise">+创建企业</view>
		</view>	
	</view>
	<view v-else class="enterprise__box" >
<!-- 		<view :class="{'enterprise__box__list':true , 'enterprise__box__list--last':index==enterpriseList.length-1}"
			 v-for="(enterprise,index) in enterpriseList"> -->
		<view class='enterprise__box__list'>
			<view class="enterprise__box__list__top">
				<view class="enterprise__box__list__top__number">{{enterprise.name}} </view>
				<view class="enterprise__box__list__top__option">
					<view  @click="editEnterprise(enterprise.id)">
						<!-- <u-icon name="edit-pen"></u-icon> -->
						<image class="enterprise__box__list__top__option__edit" src="/static/index/edit.svg" mode="aspectFit"></image>
					</view>
					<view class="enterprise__box__list__top__option__view" @click="enterpriseCard(enterprise.id)">查看详情</view>
				</view>
				
			</view>
<!-- 			<view class="enterprise__box__list__mid">
				<view class="enterprise__box__list__mid__left">
					<view class="enterprise__box__list__mid__left__park">园区：{{enterprise.park_id}}</view>
					<view class="enterprise__box__list__mid__left__address">{{enterprise.address}}</view>
				</view>
				<view class="enterprise__box__list__mid__right">
					<view class="enterprise__box__list__mid__right__phone">房间:{{enterprise.root_id}}</view>
				</view>
			</view> -->

		</view>
	</view>
	</view>
	
</template>

<script>
	import testData from './enterpriseData.js'
	export default {
		data() {
			return {
				enterpriseList:[],
				loadding:false,
				enterprise:null,
			}
		},
		mounted(){
			this.getEnterprise()
			if(this.$store.state.userInfo.enterpriseId!="")
			{
				this.getEnterprise();
			}
	
			// this.getBillList();
			// 测试数据
			// this.enterpriseList=testData.enterpriseList;
		},
		methods: {
			getEnterpriseList(){
				//请求企业列表
			},
			getEnterprise(){
				this.loadding=true
				let _this=this
				console.log("store.userinfo",_this.$store.state.userInfo)
				let queryParams={
					"enterprise_id":_this.$store.state.userInfo.enterpriseId
				}

				this.$Axios({
					method:"get",
					url:_this.$store.state.baseURL+"/enterprise/my",
				}).then((response)=>{
					this.loadding=false
					console.log("response",response)
					if(response.data.state=="Success"){
						this.enterprise=response.data.msg;
						console.log(response)
					}else{
						this.enterprise=null
						uni.showToast({
							title:response.data.msg,
							icon:"none",
							duration:2000
						})
					}
				});
			},

			enterpriseCard(enterpriseId){
				this.$Router.push({
					path:"/pages/core/mine/enterprise/enterpriseCard",
					query:{
						enterpriseId:enterpriseId
					}
				})
			},
			editEnterprise(enterpriseId){

				this.$Router.push({
					path:"/pages/core/mine/enterprise/editEnterprise",
					query:{
						enterpriseId:enterpriseId
					}
				})
			},
			addEnterprise(){
				uni.navigateTo({
					url:"/pages/core/mine/enterprise/addEnterprise"
				})
			}
		}
	}
</script>

<style lang="less">
.navbar {
	&__search{
		border-radius: 100rpx;
		display: flex;
		align-items: center;
		flex:1;
		padding: 1px @uni-spacing-col-base;
		margin-left: @uni-spacing-col-base ;
		background-color: rgb(249, 249, 249);
		&__text{
			font-size:small;
			color:@font-color-grey;
			margin-left: 10rpx;
		}
	}
	&__search{
		border: 1px solid @uni-color-primary;
	}
	&__more{
		margin-right: @uni-spacing-col-base;
		margin-left: auto;
	}
	&__return{
		margin:0 @uni-spacing-col-lg;
		font-size: small;
		color: @font-color-grey;
	}
}
.enterprise{
	background-color: @uni-bg-color-grey;
	height: calc(100vh);

	&__noresult{
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-top: @uni-spacing-row-lg;
		
		&__add{
			margin-top: @uni-spacing-row-lg;
			text-align: center;
			color: @font-color-blue;
		}
	}
	&__box{
		display: flex;
		flex-direction: column;
		margin:@uni-spacing-row-base @uni-spacing-col-base;
		padding-bottom: @uni-spacing-row-lg;
		border-radius: @border-small;
		background-color: #fff;
		
		&__name{
			display: flex;
			margin-left: @uni-spacing-col-lg;
			margin-top: @uni-spacing-col-lg;
			font-size: @uni-font-size-lg;
		}
		&__list{
			display: flex;
			flex-direction: column;
			// margin-top: @uni-spacing-row-lg;
			padding-left: @uni-spacing-col-lg;
			padding-right: @uni-spacing-col-lg;
			// border-top: 0.01rpx solid @uni-border-color;
			&__top{
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: @uni-spacing-row-base;
				&__number{
					font-weight: bold;
				}
				&__option{
					display: flex;
					flex-direction: row;
					align-items: center;
					&__edit{
						// color: #007AFF;
						margin-left: @uni-spacing-col-base;
						width: @icon-base;
						height: @icon-base;	
					}
					&__view{
						margin-left: @uni-spacing-col-base;
						padding: 15rpx 20rpx;
						border-radius: 15rpx;
						background-color: #f5f5f5;
						// background-color: #007AFF ;
						// color: #fff;
						color: #007AFF;
						// font-weight: lighter;
						// font-size: @uni-font-size-sm;
					}

				}
			}
			&__mid{
				display: flex;
				justify-content: space-between;
			
				margin-top: @uni-spacing-row-lg;
				padding-bottom: @uni-spacing-row-sm;
				
				&__left{
					display: flex;
					flex-direction: column;
					&__park{
						
					}
					&__address{
						margin-top: @uni-spacing-row-x-sm;
						font-size: @uni-font-size-sm;
						color: @uni-text-color-grey;
					}
				}
				&__right{
					&__phone{
						// font-size: @uni-font-size-lg;
					}
				}
				
			}
		}
		&__list--last{
			border-bottom: 0;
		}
	}
}	

</style>
